/**
 *    Copyright 2012 Geensoft S.A.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 **/
package ar.com.greensoft.neo.web.jsf.beans.common;

import javax.faces.bean.ApplicationScoped;
import javax.faces.bean.ManagedBean;
import javax.faces.context.FacesContext;
import javax.faces.model.SelectItem;

import org.springframework.stereotype.Component;

import ar.com.greensoft.neo.model.references.EstadoCivil;
import ar.com.greensoft.neo.model.references.RazonSocial;
import ar.com.greensoft.neo.model.references.Sexo;
import ar.com.greensoft.neo.model.references.TipoDocumento;
import ar.com.greensoft.neo.web.jsf.util.ResourceBundleUtil;

/**
 * @author Jorge E. Villaverde
 * @version 1.0.0
 * @since 26/09/2011	
 */
@Component
@ApplicationScoped
@ManagedBean
public class EnumRefereceBean {

	public SelectItem[] getEstodosCiviles(){
		FacesContext context = FacesContext.getCurrentInstance();
		SelectItem[] items = new SelectItem[EstadoCivil.values().length];
		int i = 0;
		for(EstadoCivil value : EstadoCivil.values()) {
			items[i++] = new SelectItem(value, 
					ResourceBundleUtil.getResourceBundleString(value.getLabel(), 
							context.getViewRoot().getLocale()));
		}
		return items;		
	}

	public SelectItem[] getSexos(){
		FacesContext context = FacesContext.getCurrentInstance();
		SelectItem[] items = new SelectItem[Sexo.values().length];
		int i = 0;
		for(Sexo value : Sexo.values()) {
			items[i++] = new SelectItem(value, 
					ResourceBundleUtil.getResourceBundleString(value.getLabel(), 
							context.getViewRoot().getLocale()));
		}
		return items;		
	}
		
	public SelectItem[] getRazonesSociales(){
		FacesContext context = FacesContext.getCurrentInstance();
		SelectItem[] items = new SelectItem[RazonSocial.values().length];
		int i = 0;
		for(RazonSocial value : RazonSocial.values()) {
			items[i++] = new SelectItem(value, 
					ResourceBundleUtil.getResourceBundleString(value.getLabel(), 
							context.getViewRoot().getLocale()));
		}
		return items;		
	}
	
	public SelectItem[] getTiposDocumentos(){
		FacesContext context = FacesContext.getCurrentInstance();
		SelectItem[] items = new SelectItem[TipoDocumento.values().length];
		int i = 0;
		for(TipoDocumento value : TipoDocumento.values()) {
			items[i++] = new SelectItem(value, 
					ResourceBundleUtil.getResourceBundleString(value.getLabel(), 
							context.getViewRoot().getLocale()));
		}
		return items;		
	}
}
